import React, { Component } from "react";
import styled from "styled-components";
const Title = styled.div`
  color: green;
  font-size: 24px;
`;
class Counter extends Component<any, any> {
  constructor(props: any) {
    super(props);
    this.state = {
      content: "这里是计数更新页面",
      count: 0,
    };
    this.handleClick = this.handleClick.bind(this);
  }
  handleClick(e: any) {
    e.preventDefault();
    this.setState({
      count: this.state.count + 1,
    });
  }
  render() {
    return (
      <>
        <Title>{this.state.content}</Title>
        <p>{this.state.count}</p>
        <button
          onClick={(e) => {
            this.handleClick(e);
          }}
        >
          点击跳转
        </button>
      </>
    );
  }
}
export default Counter;
